package com.topica.network;

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.serialization.PropertyInfo;

import android.content.Context;
import android.util.Log;

import com.topica.database.task.TopicaDBTask;

public class UpdateCourse extends TopicaDBTask {
	private static final String METHOD_UPDATE_COURSE = "updateCourse";
	private String userId;
	private String courseId;

	public UpdateCourse(Context context, String userId, String courseId) {
		super(context);
		this.userId = userId;
		this.courseId = courseId;
	}

	@Override
	protected void onPreExecute() {

	}

	@Override
	protected Integer doInBackground(Void... params) {
		PropertyInfo pi = new PropertyInfo();
		pi.setName("user_id");
		pi.setValue(userId);

		PropertyInfo pi1 = new PropertyInfo();
		pi1.setName("course_id");
		pi1.setValue(courseId);

		List<PropertyInfo> pList = new ArrayList<PropertyInfo>();
		pList.add(pi);
		pList.add(pi1);
		SoapCaller caller = new SoapCaller();
		boolean value = caller.updateCourse(METHOD_UPDATE_COURSE, pList);
		if (value) {
			return OK;
		} else
			return FAIL;
	}

	@Override
	protected void onPostExecute(Integer result) {
		if (result == OK)
			Log.i("UpdateCourse", "Update OK");
		else
			Log.i("UpdateCourse", "Update FAIL");
	}
}
